<script>
/*
## 矩形

写一个类名字叫Rectangle（矩形）
构造方法应该采用4个参数 x,y,width,height
赋值给4个属性x,y,width,height
有toString方法，返回"(x=1, y=2, width=3, height=4)"
有5个getter属性
- left
- right
- top
- bottom
- area （面积）

如

```js
let r = new Rectangle(100, 20, 50, 75)
r.left // 100
r.right // 150
r.top // 20
r.bottom // 95
r.area // 3750
```
*/
class Rectangle{
    x
    y
    width
    height

constructor(x,y,width,height){
   this.x=x
   this.y=y
   this.width=width
   this.height=height
} 
get left(){
    return this.x
}
get right(){
    return this.x+this.width
}
get top(){
    return this.y
}
get bottom(){
    return this.y+this.height
}
get area(){
    return this.width*this.height
}
toSting(){
    return `x=${this.x},y=${this.y},width=${this.width},height=${this.height}`
}
}
let r = new Rectangle(100, 20, 50, 75)
console.log(r.left)
console.log(r.right)
console.log(r.top)
console.bottom(r.bottom)
console.area(r.area)


</script>